package com.lanhe.app.controller.article;


import com.lanhe.common.core.controller.BaseController;
import com.lanhe.common.core.domain.AjaxResult;
import com.lanhe.common.core.page.TableDataInfo;
import com.lanhe.notice.domain.LhNotice;
import com.lanhe.notice.service.ILhNoticeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公告表(LhNotice)表控制层
 *
 * @author zhanggl
 * @since 2023-12-30 14:00:35
 */
@RestController
@RequestMapping("/api/notice")
public class ApiNoticeController extends BaseController {

    /**
     * 服务对象
     */
    @Resource
    private ILhNoticeService lhNoticeService;

    /**
     * 分页查询所有数据
     */
    @GetMapping("/list")
    public TableDataInfo list(LhNotice notice) {
        startPage();
        List<LhNotice> list = lhNoticeService.selectNoticeList(notice);
        return getDataTable(list);
    }

    /**
     * 根据编号获取详细信息
     */
    @GetMapping(value = {"/", "/{noticeId}"})
    public AjaxResult getInfo(@PathVariable(value = "noticeId") Long noticeId) {
        return success(lhNoticeService.selectNoticeById(noticeId));
    }

    /**
     * 获取最新一条
     */
    @GetMapping(value = {"/lastOne"})
    public AjaxResult lastOne() {
        return success(lhNoticeService.lastOne());
    }
}

